package test.com.sky.designPattern.statePattern;

import com.sky.JULLog.MyLogger;

import java.util.logging.Logger;

public class ThreadStateDemo {


    private static Logger log = MyLogger.getLogger(ThreadStateDemo.class);


    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() -> {
            for (int i = 0; i < 20; i++) {
                try {
                    Thread.sleep(2000);
                    log.info(Thread.currentThread().getState().name() + i);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });


        log.info(thread.getState().name());

        thread.start();
        Thread.sleep(1000);
        //以下几种状态都会报异常;  因为在运行状态下, 有些 事情不能做;
        //        thread.start();
        //      thread.wait();
        //  thread.setDaemon(true);
    }


}
